<template>
	<view class="uiwu">
		<view class="uiwu-zanwei">
			<view class="uiwu-fixed">
				<view class="uiwu-header">
					<view class="box uiwu-flex-align">
						<image src="@/static/image/search.png" mode="widthFix"></image>
						<input type="text" v-model="keyword" placeholder="请输入搜索关键词" confirm-type="search"
							@confirm="swiperTab(activeIndex)">
					</view>
				</view>
				<!-- <view class="uiwu-scroll">
					<scroll-view scroll-x>
						<view class="uiwu-scroll-list uiwu-flex-space">
							<view 
								class="item" 
								:class="index == activeIndex ? 'active' : ''" 
								v-for="(item,index) in menuTablist" 
								:key="index"
								@tap="swiperTab(index)"
							>
								{{item}}
							</view>
						</view>
					</scroll-view>
				</view> -->
			</view>
		</view>
		<uiwu-list :loading="more">
			<view class="uiwu-list">
				<view class="uiwu-list-item uiwu-flex-space" v-for="(item, index) in listData" :key="index">
					<image :src="item.avatar" mode="aspectFill"></image>
					<view class="in uiwu-flex-column">
						<text>{{ item.nickname }}</text>
						<text>注册时间: {{ uiwu.formatTimestamp(item.add_time * 1000) }}</text>
					</view>
					<view class="right">
						充值：{{ item.recharge_amount }}
					</view>
				</view>
			</view>
		</uiwu-list>
	</view>
</template>

<script setup lang="ts">
import { spreadpeople, uiwu } from '@/api/interface/interface';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { inject, ref } from 'vue';
const menuTablist = ref<Array<string>>(['全部粉丝', '一级粉丝', '二级粉丝'])
const activeIndex = ref<number>(0)
const listData = ref<Array<object>>([])
const pageNum = ref<number>(1)
const more = ref<string>('loading');
const isLock = ref<boolean>(true)
const keyword = ref<string>("")
const getspreadpeople = async (mack: boolean = false): Promise<any> => {
	if (!mack) pageNum.value = 1
	const { data: { data, total } } = await spreadpeople({
		page: pageNum.value,
		grade: activeIndex.value,
		keyword: keyword.value
	});
	isLock.value = true
	uiwu.setlist({
		isMore: mack,
		listData,
		total,
		listRow: data,
		more,
		pageNum
	})
}
const swiperTab = (index: number): void => {
	activeIndex.value = index
	getspreadpeople()
}
onReachBottom(() => {
	if (!isLock.value) return
	isLock.value = false
	pageNum.value++
	getspreadpeople(true)
})
onLoad(() => {
	getspreadpeople()
})
</script>

<style lang="scss" scoped>
//统一样式格式化
view,
text,
button,
input,
textarea,
navigator {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

//button按钮特殊处理
button {
	&::after {
		border: 0;
		padding: 0;
		margin: 0;
	}
}

//图片默认格式处理，防止切换页面导致图片闪烁
image {
	will-change: transform;
	width: 0;
	height: 0;
}

page {
	background-color: #e6e6e6;
}

.uiwu-zanwei {
	height: 102rpx;
}

.uiwu-fixed {
	position: fixed;
	left: 0;
	right: 0;
	top: 0;
	z-index: 98;
}

.uiwu-header {
	height: 102rpx;
	width: 100%;
	background-color: #272323;
	padding: 10rpx 24rpx 20rpx;

	image {
		width: 32rpx;
		margin-right: 20rpx;
	}

	.box {
		width: 100%;
		height: 100%;
		border: 3rpx solid rgba(#FFFFFF, 0.2);
		border-radius: 36rpx;
		padding: 0 30rpx;

		input {
			font-size: 28rpx;
			flex: 1;
			color: #FFF;
		}
	}
}

.uiwu-list {
	background-color: #fff;
	margin-top: 20rpx;
	padding: 0 24rpx;

	&-item {
		padding: 20rpx 0;

		image {
			width: 88rpx;
			height: 88rpx;
			border-radius: 50%;
			margin-right: 24rpx;
		}

		.in {
			flex: 1;

			text {
				&:nth-child(1) {
					font-size: 28rpx;
					font-weight: bold;
					color: #231815;
					margin-bottom: 5rpx;
				}

				&:nth-child(2) {
					font-size: 24rpx;
					font-weight: 300;
					color: #999999;
				}
			}
		}

		.right {
			font-size: 24rpx;
			font-weight: normal;
			color: #231815;
		}
	}
}

.uiwu-scroll {
	background-color: #272323;
	width: 100%;
	height: 92rpx;
	padding-bottom: 10rpx;

	&-list {
		padding: 0 24rpx;
		height: 82rpx;

		.item {
			flex-shrink: 0;
			font-size: 28rpx;
			font-weight: 500;
			color: #FFFFFF;
			height: 55rpx;
			line-height: 55rpx;

			&.active {
				text-align: center;
				width: 176rpx;
				background: url('../../static/indextab.png') no-repeat 0 0;
				background-size: 100% 100%;
				font-size: 32rpx;
				font-family: PingFang SC-Heavy, PingFang SC;
				font-weight: 800;
				color: #FFFFFF;
				line-height: inherit;
				text-shadow: 0px 4rpx 0rpx #231815;
			}
		}
	}
}
</style>
